package com.suning.generator.util;

import com.intellij.notification.*;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;

/**
 * 通知消息
 *
 * @author bail
 * @date 2020/4/26
 */
public class NotifyUtils {

    private static final NotificationGroup NOTIFICATION = new NotificationGroup("my-generator-intellij-plugin", NotificationDisplayType.BALLOON, false);

    public static final String COMMAND_COPIED = "生成的单元测试代码已经复制到剪贴板";

    /**
     * 通知默认内容的消息
     */
    public static void notifyMessage(Project project) {
        notifyMessage(project, COMMAND_COPIED);
    }

    /**
     * 通知自定义内容的消息
     */
    public static void notifyMessage(Project project, String message) {
        try {
            Notification currentNotify = NOTIFICATION.createNotification(message, NotificationType.INFORMATION);
            Notifications.Bus.notify(currentNotify, project);
        } catch (Exception e) {
            //
        }
    }

    /**
     * 通知不同类型的自定义内容消息
     */
    public static void notifyMessage(Project project, String message, @NotNull NotificationType type) {
        try {
            Notification currentNotify = NOTIFICATION.createNotification(message, type);
            Notifications.Bus.notify(currentNotify, project);
        } catch (Exception e) {
            //
        }
    }

}
